// ============================================================================
//
// Copyright (C) 2009-2011 SC Technology Group. - www.sc.com
//
// ============================================================================
package com.cs.vessel.breakdown.view.providers;

import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;

import com.cs.vessel.breakdown.Activator;
import com.sc.vessel.info.model.breakdown.Accident;
import com.sc.vessel.info.model.breakdown.ConfigElementSelected;

/**
 * DOC liaoqc class global comment. Detailled comment
 */
public class AccidentViewLabelProvider extends LabelProvider implements ITableLabelProvider {

    public String getColumnText(Object obj, int index) {
        Accident accident = (Accident) obj;

        switch (index) {
        case 0:
            return accident.getPhenomenon();
        case 1:
            return accident.getComponent().getName();
            // case 2:
            // return accident.getAnalyze();
            // case 3:
            // return accident.getExperience();
        default:
            break;
        }
        Object object = accident.getConfigElements().get(index - 2);
        if (object instanceof ConfigElementSelected) {
            ConfigElementSelected configElementSelected = (ConfigElementSelected) object;
            return configElementSelected.getSelectedValue() == null ? "" : configElementSelected.getSelectedValue();
        } else
            return "";
    }

    public Image getColumnImage(Object obj, int index) {
        if (index == 0) {
            return getImage(obj);
        }
        return null;
    }

    public Image getImage(Object obj) {
        return Activator.getImageDescriptor("/icons/accident.gif").createImage();
    }

}
